package com.ranjiaqi.caledar;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test{
    public static void main(String[] args) throws ParseException {
        StringToDate();
    }
    public static void StringToDate()throws ParseException{
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str="2021-8-7 15:00:01";
        String str1="2020-8-7 1:00:01";
        Date date=sdf.parse(str);
        Date date1=sdf.parse(str1);
        System.currentTimeMillis();
        long a= date.getTime();
        System.currentTimeMillis();
        long b= date1.getTime();
        long c=a-b;

        new Date(c).setTime(c);
        System.out.println(new Date(c));
    }
}
